<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>key解决组件复用问题</title>
    <script src="./vue.js"></script>
</head>
<body>
<div id="app">
    <div v-if="show">
        用户名:<input key="username"/>
    </div>
    <div v-else>
        邮箱:<input key="email"/>
    </div>
</div>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            show: false
        }
    });
</script>
</body>
</html>